<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Member extends Model
{
	use SoftDeletes;

	const MALE   = 1;
	const FEMALE = 2;
	const SEXES  = [
		self::MALE   => '男',
		self::FEMALE => '女'
	];

	public static function rules()
	{
		return [
			'avatar'   => 'alpha_dash|max:32',
			'name'     => 'required|string|max:8',
			'mobile'   => 'string|max:11',
			'birthday' => 'date|before:now',
			'sex'      => 'in:1,2',
		];
	}

	public static function messages()
	{
		return [
			'avatar.alpha_dash' => '请上传正确的头像',
			'avatar.max'        => '请上传正确的头像',
			'name.required'     => '请输入姓名',
			'name.string'       => '请输入正确的姓名',
			'name.max'          => '请输入至多8字姓名',
			'mobile.string'     => '请输入手机号',
			'mobile.max'        => '请输入至多11位手机号',
			'birth.date'        => '请选择正确的生日',
			'birth.before'      => '请选择正确的生日',
			'sex.in'            => '请选择正确的性别',
		];
	}
}
